<?php

/* 会员 buyer */
class StyleModel extends BaseModel
{
    var $table  = 'style';
    var $prikey = 'style_id';
    var $_name  = 'style';
	
    var $_relation = array(
		'has_sample' => array(
			'model' => 'sample',
			'type' => HAS_MANY,
			'foreign_key' => 'style_id',
			'dependent' => true,
		),
	);

    /*
     * 判断名称是否唯一
     */
    function unique($style_name, $style_id = 0)
    {
        $conditions = "style_name = '" . $style_name . "'";
        $style_id && $conditions .= " AND style_id <> '" . $style_id . "'";
        return count($this->find(array('conditions' => $conditions))) == 0;
    }
}

?>